<?php

function smarty_function_yuivmenu($params, &$smarty)
{

	$content = $params['Content'];

	

//print_r($content);

	$out = '';
        $out .= "<div id=\"panel1\">
                        <div class=\"hd\">добавить раздел</div>
                        <form  id=\"form_add_new\" action=\"admin.php5\">
                        <input type=\"hidden\" name=\"action\" value=\"addnew\">
                        <input type=\"hidden\" name=\"parent\" value=\"0\">
                        <input type=\"hidden\" name=\"sortorder\" value=\"$size\">
                        <input type=\"hidden\" name=\"type\" value=\"1\">
                        <div class=\"bd\">Название: <input type=\"text\" name=\"value\"></div>
                        <div class=\"ft\"><input type=\"submit\" value=\"Ok\">&nbsp;<input id=\"hide_add\" type=\"button\" value=\"Cancel\"></div>
                        </form>
                </div>";

        $out .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"../../build/menu/assets/menu.css\">";
        $out .="        <!-- Container source file -->
        <script type=\"text/javascript\" src=\"../../build/container/container_core.js\"></script>

        <!-- Menu source file -->
        <script type=\"text/javascript\" src=\"../../build/menu/menu.js\"></script>";

        $out .= "<script type=\"text/javascript\">

            YAHOO.example.onMenuReady = function() {
                
                // \"beforerender\" event handler for the menu

                function onMenuBeforeRender(p_sType, p_sArgs, p_oMenu) {

                    var oSubmenuData = {
                    
//                        \"information\": [
//                            { text: \"Downloads\", url: \"http://downloads.yahoo.com\" },
//                        ]
                    
                    };


//                    this.getItem(1).cfg.setProperty(\"submenu\", { id:\"information\", itemdata: oSubmenuData[\"information\"] });

                }


                // Instantiate and render the menu

                var oMenu = new YAHOO.widget.Menu(\"leftmenu\", { position:\"static\", hidedelay:750, lazyload:true });


                // Subscribe to the \"beforerender\" event

                oMenu.beforeRenderEvent.subscribe(onMenuBeforeRender, oMenu, true);

                oMenu.render();
                
            };


            // Initialize and render the menu when it is available in the DOM

            YAHOO.util.Event.onContentReady(\"leftmenu\", YAHOO.example.onMenuReady);

        </script>";

        $out .= "<div id=\"leftmenu\" class=\"yuimenu\">
                            <div class=\"bd\">
                                <ul class=\"first-of-type\">";

        $class = 'yuimenuitem';

        $out .= "<li class=\"yuimenuitem\" id=\"show_add\"> <добавить> </li><li></li>";

		$size = 1;
        foreach ($content as $item){
                //print_r($item)."<br>";
                $class = 'yuimenuitem';
                if ($item->property == 'public' && $item->parent == 0 ) {
                        $list .= "<li class=\"$class\">" .
//                        		"<a href=\"#up\"><img src=\"/img/up.gif\" border=\"0\" alt=\"up\" title=\"up\"></a>&nbsp;" .
                        		"<a href=\"admin.php5?go=$item->id\">$item->value</a>&nbsp;" .
//                        		"<a href=\"#down\"><img src=\"/img/down.gif\" border=\"0\" alt=\"down\" title=\"down\"></a>" .
                        		"</li>";
                        $size++;
                }
        }



        
        $out .= "<script>
                YAHOO.namespace(\"example.container\");

                function init() {
                        YAHOO.example.container.panel1 = new YAHOO.widget.Panel(\"panel1\", { width:\"300px\", visible:false, constraintoviewport:true } );
                        YAHOO.example.container.panel1.render();
//                        YAHOO.example.container.panel2 = new YAHOO.widget.Panel(\"panel2\", { width:\"300px\", visible:false, draggable:false, close:false } );
//                        YAHOO.example.container.panel2.setBody(\"This is a dynamically generated Panel.\");
//                        YAHOO.example.container.panel2.setFooter(\"End of Panel #2\");
//                        YAHOO.example.container.panel2.render(document.body);


                        YAHOO.util.Event.addListener(\"show_add\", \"click\", YAHOO.example.container.panel1.show, YAHOO.example.container.panel1, true);
                        YAHOO.util.Event.addListener(\"hide_add\", \"click\", YAHOO.example.container.panel1.hide, YAHOO.example.container.panel1, true);
                }

                YAHOO.util.Event.addListener(window, \"load\", init);
                </script>";

		
		$out .= $list;


//                                        <li class=\"yuimenubaritem first-of-type\"><a href=\"http://communication.yahoo.com\">Communication</a></li>
                            
        $out .= "               </ul>
                            </div> 
                        </div>";
       
	return $out;
} 

/* vim: set expandtab: */

 
?>
